package algorithm.view.prepare;

import java.awt.*;
import java.awt.event.*;


/**
 * @author bingo
 * @Description 菜单
 * @Date 2018/7/20
 */
public class Demo5 {
    public static void main(String[] args) {
        Frame f = new Frame();
        f.setSize(400,400);
        f.setVisible(true);
        f.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
        f.setLayout(new FlowLayout());
        Button button1 = new Button("青色");

        MenuBar menuBar = new MenuBar();
        Menu menu = new Menu("aa");
        MenuItem menuItem = new MenuItem("aaaaa");
        Menu menu2 = new Menu("bb");
        MenuItem menuItem2 = new MenuItem("bbbb");

        menuBar.add(menu);
        menu.add(menuItem);
        menu.add(menu2);
        menu2.add(menuItem2);


        f.add(button1);
        f.setMenuBar(menuBar);
        button1.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e){
                f.setBackground(Color.cyan);
            }
        });


    }
}
